<!doctype html>


<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>xhr.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>





<div class="colmask rightmenu">
<div class="colleft">
    <div class="col1">
      <!-- Column 1 start -->

<div id="title">
       <span class="fn">xhr.js</span>
</div>

<div class="g-section g-tpl-75-25">
  <div class="g-unit g-first" id="description">
    <span class='nodesc'>No description.</span>
  </div>
  

        <div class="g-unit" id="useful-links">
          <div class="title">Useful links</div>
          <ol>
            <li><a href="local_closure_goog_labs_net_xhr.js.source.html"><span class='source-code-link'>Source Code</span></a></li>
            <li><a href="http://code.google.com/p/closure-library/source/browse/local/closure/goog/labs/net/xhr.js">Git</a></li>
          </ol>
        </div>
</div>

<h2 class="g-first">File Location</h2>
  <div class="g-section g-tpl-20-80">
    <div class="g-unit g-first">
      <div class="g-c-cell code-label">/goog/labs/net/xhr.js</div>
    </div>
  </div>
<hr/>


  <h2>Classes</h2>
 <div class="fn-constructor">
        <a href="class_goog_labs_net_xhr_Error.html">
          goog.labs.net.xhr.Error</a><br/>
        <div class="class-details">Generic error that may occur during a request.

</div>
 </div>
 <div class="fn-constructor">
        <a href="class_goog_labs_net_xhr_HttpError.html">
          goog.labs.net.xhr.HttpError</a><br/>
        <div class="class-details">Class for HTTP errors.

</div>
 </div>
 <div class="fn-constructor">
        <a href="class_goog_labs_net_xhr_TimeoutError.html">
          goog.labs.net.xhr.TimeoutError</a><br/>
        <div class="class-details">Class for Timeout errors.

</div>
 </div>
      
<br/>

  <div class="legend">
        <span class="key publickey"></span><span>Public</span>
        <span class="key protectedkey"></span><span>Protected</span>
        <span class="key privatekey"></span><span>Private</span>
  </div>









<div class="section">
  <table class="horiz-rule">


  </table>
</div>




  <h2>Global Functions</h2>





<div class="section">
  <table class="horiz-rule">


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.xhr.get"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.labs.net.xhr.</span><span class="entryName">get<span class="args">(<span class="arg">url</span>,&nbsp;<span class="arg">opt_options</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="class_goog_Promise.html">goog.Promise</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>&gt;
      </div>


     <div class="entryOverview">
       Sends a get request, returning a promise that will be resolved
with the response text once the request completes.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">url</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The URL to request.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_options</span>
        : <span class="type">_.Options=</span>
        <div class="entryOverview">Configuration options for the request.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="class_goog_Promise.html">goog.Promise</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>&gt;&nbsp;
            A promise that will be resolved with the
    response text once the request completes.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_xhr.js.source.html#line101">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.xhr.getJson"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.labs.net.xhr.</span><span class="entryName">getJson<span class="args">(<span class="arg">url</span>,&nbsp;<span class="arg">opt_options</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="class_goog_Promise.html">goog.Promise</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>&gt;
      </div>


     <div class="entryOverview">
       Sends a get request, returning a promise that will be resolved with
the parsed response text once the request completes.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">url</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The URL to request.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_options</span>
        : <span class="type">_.Options=</span>
        <div class="entryOverview">Configuration options for the request.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="class_goog_Promise.html">goog.Promise</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>&gt;&nbsp;
            A promise that will be resolved with the
    response JSON once the request completes.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_xhr.js.source.html#line134">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.xhr.isEffectiveSchemeHttp_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.labs.net.xhr.</span><span class="entryName">isEffectiveSchemeHttp_<span class="args">(<span class="arg">url</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">url</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The URL to test.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Boolean">boolean</a></span>&nbsp;
            Whether the effective scheme is HTTP or HTTPs.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_xhr.js.source.html#line260">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.xhr.send&function%0&xhr.onerror"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.labs.net.xhr.send&function%0&xhr.</span><span class="entryName">onerror<span class="args">()</span>
        </span>
      </div>


     <div class="entryOverview">
       <span class='nodesc'>No description.</span>
     </div>

   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_xhr.js.source.html#line197">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.xhr.parseJson_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.labs.net.xhr.</span><span class="entryName">parseJson_<span class="args">(<span class="arg">responseText</span>,&nbsp;<span class="arg">options</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>
      </div>


     <div class="entryOverview">
       JSON-parses the given response text, returning an Object.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">responseText</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">Response text.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">options</span>
        : <span class="type">_.Options</span><span>&nbsp;|&nbsp;</span><span class="type">undefined</span>
        <div class="entryOverview">The options object.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>&nbsp;
            The JSON-parsed value of the original responseText.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_xhr.js.source.html#line276">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.xhr.post"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.labs.net.xhr.</span><span class="entryName">post<span class="args">(<span class="arg">url</span>,&nbsp;<span class="arg">data</span>,&nbsp;<span class="arg">opt_options</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="class_goog_Promise.html">goog.Promise</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>&gt;
      </div>


     <div class="entryOverview">
       Sends a post request, returning a promise that will be resolved
with the response text once the request completes.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">url</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The URL to request.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">data</span>
        : <span class="type">_.PostData</span>
        <div class="entryOverview">The body of the post request.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_options</span>
        : <span class="type">_.Options=</span>
        <div class="entryOverview">Configuration options for the request.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="class_goog_Promise.html">goog.Promise</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>&gt;&nbsp;
            A promise that will be resolved with the
    response text once the request completes.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_xhr.js.source.html#line118">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.xhr.postJson"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.labs.net.xhr.</span><span class="entryName">postJson<span class="args">(<span class="arg">url</span>,&nbsp;<span class="arg">data</span>,&nbsp;<span class="arg">opt_options</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="class_goog_Promise.html">goog.Promise</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>&gt;
      </div>


     <div class="entryOverview">
       Sends a post request, returning a promise that will be resolved with
the parsed response text once the request completes.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">url</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The URL to request.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">data</span>
        : <span class="type">_.PostData</span>
        <div class="entryOverview">The body of the post request.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">opt_options</span>
        : <span class="type">_.Options=</span>
        <div class="entryOverview">Configuration options for the request.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="class_goog_Promise.html">goog.Promise</a></span>.&lt;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Object">Object</a></span>&gt;&nbsp;
            A promise that will be resolved with the
    response JSON once the request completes.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_xhr.js.source.html#line151">code &raquo;</a>
  </td>
     </tr>


     <tr class="odd entry public">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.xhr.send"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.labs.net.xhr.</span><span class="entryName">send<span class="args">(<span class="arg">method</span>,&nbsp;<span class="arg">url</span>,&nbsp;<span class="arg">data</span>,&nbsp;<span class="arg">opt_options</span>)</span>
        </span>
        &#8658; <span>!</span><span class="type"><a href="class_goog_Promise.html">goog.Promise</a></span>.&lt;<span>!</span><span class="type">goog.net.XhrLike.OrNative</span>&gt;
      </div>


     <div class="entryOverview">
       Sends a request, returning a promise that will be resolved
with the XHR object once the request completes.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">method</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The HTTP method for the request.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">url</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The URL to request.</div>
     </td>
   </tr>
     
   <tr class="even">
     <td>
        <span class="entryName">data</span>
        : <span class="type">_.PostData</span>
        <div class="entryOverview">The body of the post request.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">opt_options</span>
        : <span class="type">_.Options=</span>
        <div class="entryOverview">Configuration options for the request.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span>!</span><span class="type"><a href="class_goog_Promise.html">goog.Promise</a></span>.&lt;<span>!</span><span class="type">goog.net.XhrLike.OrNative</span>&gt;&nbsp;
            A promise that will be
    resolved with the XHR object once the request completes.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_xhr.js.source.html#line169">code &raquo;</a>
  </td>
     </tr>


     <tr class="even entry private">
       <td class="access"></td>






  <td>
    <a name="goog.labs.net.xhr.stripXssiPrefix_"></a>


     <div class="arg">
       <img align="left" src="static/images/blank.gif">

        <span class="entryNamespace">goog.labs.net.xhr.</span><span class="entryName">stripXssiPrefix_<span class="args">(<span class="arg">prefix</span>,&nbsp;<span class="arg">string</span>)</span>
        </span>
        &#8658; <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
      </div>


     <div class="entryOverview">
       Strips the XSSI prefix from the input string.


     </div>


    <! -- Method details -->
    <div class="entryDetails">

      <div class="detailsSection">
        <b>Arguments: </b>






<table class="horiz-rule">
     
   <tr class="even">
     <td>
        <span class="entryName">prefix</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The XSSI prefix.</div>
     </td>
   </tr>
     
   <tr class="odd">
     <td>
        <span class="entryName">string</span>
        : <span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>
        <div class="entryOverview">The string to strip the prefix from.</div>
     </td>
   </tr>
  </table>
      </div>
   
      <div class="detailsSection">
        <b>Returns:</b>&nbsp;<span class="type"><a href="https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/String">string</a></span>&nbsp;
            The input string without the prefix.
      </div>
  
    </div>
   
  </td>


  <td class="view-code">
     <a href="local_closure_goog_labs_net_xhr.js.source.html#line294">code &raquo;</a>
  </td>
     </tr>


  </table>
</div>






      <!-- Column 1 end -->
    </div>

        <div class="col2">
          <!-- Column 2 start -->
          <div class="col2-c">
            <h2 id="ref-head">Directory net</h2>
            <div id="localView"></div>
          </div>

          <div class="col2-c">
            <h2 id="ref-head">File Reference</h2>
            <div id="sideFileIndex" rootPath="" current="/goog/labs/net/xhr.js"></div>
          </div>
          <!-- Column 2 end -->
        </div>
</div>
</div>

</body>
</html>
